package ref;

import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.util.List;

import org.apache.log4j.Logger;

import util.UsualUtil;
import util.XxlsData;

public class Qproduct implements XxlsData {
	private static Logger log = Logger.getLogger("Qproduct");
	public void dataType(PreparedStatement ps, List<String> rowlist) {
		try {
			for (int j = 0; j < rowlist.size(); j++) {
	        	switch (j) {
				case 0: 	ps.setInt(1, Integer.valueOf(rowlist.get(0).toString().trim()));break;
				case 1: 	ps.setString(2, rowlist.get(1).toString().trim());break;
				case 2: 	ps.setString(3, rowlist.get(2).toString().trim());break;
				case 3: 	ps.setString(4, rowlist.get(3).toString().trim());break;
				case 4: 	ps.setString(5, rowlist.get(4).toString().trim());break;
				case 5: 	ps.setString(6, rowlist.get(5).toString().trim());break;
				case 6: 	ps.setString(7, rowlist.get(6).toString().trim());break;
				case 7: 	
					DecimalFormat df = new DecimalFormat("#.00");
					float jhj = Float.valueOf(rowlist.get(7).toString().trim());
					ps.setFloat(8, Float.valueOf(df.format(jhj)));break;
				case 8: 	
					int shuliang = 0;
					if(rowlist.get(8).toString().trim().startsWith("0.")) {
						shuliang = 1;
					} else {
						BigDecimal bd = new BigDecimal(rowlist.get(8).toString().trim()).setScale(0, BigDecimal.ROUND_HALF_UP);
						shuliang = bd.intValue();
					}
					ps.setInt(9, shuliang);break;
				case 9:		ps.setFloat(10, Float.valueOf(rowlist.get(9).toString().trim()));break;
				case 10: 	
					if(UsualUtil.emptyOrNot(rowlist.get(10).toString().trim())) {
						ps.setInt(11, Integer.valueOf(rowlist.get(10).toString().trim()));
					} else {
						ps.setString(11, "");
					}
					break;
//					ps.setInt(11, Integer.valueOf(rowlist.get(10).toString().trim()));break;
				case 11: 	ps.setString(12, rowlist.get(11).toString().trim());break;
				case 12: 	ps.setString(13, rowlist.get(12).toString().trim());break;
				case 13: 	ps.setString(14, rowlist.get(13).toString().trim());break;
				case 14: 	ps.setString(15, rowlist.get(14).toString().trim());break;
				case 15:		ps.setString(16, rowlist.get(15).toString().trim());break;
				case 16:		
					if(UsualUtil.emptyOrNot(rowlist.get(16).toString().trim())) {
						ps.setInt(17, Integer.valueOf(rowlist.get(16).toString().trim()));
					} else {
						ps.setString(17, "");
					}
					break;
				case 17:		ps.setString(18, rowlist.get(17).toString().trim());break;
				case 18:		ps.setString(19, rowlist.get(18).toString().trim());break;
				case 19:		ps.setString(20, rowlist.get(19).toString().trim());break;
				case 20:		ps.setString(21, "");break;
				default: 	log.info(System.err);
				}
			}
		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
}